package com.xthink.web.controller;

import com.xthink.common.result.AjaxResult;

import com.xthink.common.pojo.sys.Menu;
import com.xthink.web.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    //添加菜单
    @PostMapping("/insert")
    public AjaxResult insertMenu(@RequestBody Menu menu){
        return menuService.insertMenu(menu);
    }

    //编辑菜单
    @PostMapping("/update")
    public AjaxResult updateMenu(@RequestBody Menu menu){
        return menuService.updateMenu(menu);
    }

    //逻辑删除菜单
    @GetMapping("/delete/{id}")
    public AjaxResult deleteMenu(@PathVariable("id")Integer id){
        return menuService.deleteMenu(id);
    }

    //查询所有菜单
    @PostMapping("/list")
    public AjaxResult listMenu(){
        return menuService.listMenu();
    }
}
